home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / MSG Demo 1.4 / source / Demo ƒ / demo generic open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.8 KB  |  67 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        demo generic open.c
  4.  
  5. Purpose:    This module handles opening documents via apple events.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program in a file named "GNU General Public License".
  19. If not, write to the Free Software Foundation, 675 Mass Ave,
  20. Cambridge, MA 02139, USA.
  21.  
  22. \**********************************************************************/
  23.  
  24. #include "demo generic open.h"
  25. #include "error.h"
  26. #include "debinhex dispatch.h"
  27. #include "environment.h"
  28. #include "dialogs.h"
  29. #include "file management.h"
  30.  
  31. void GenericOpen(FSSpec *myFSS)
  32. {
  33.     int            resultCode;
  34.     
  35.     if (!gInProgress)
  36.     {
  37.         switch (GetFileType(myFSS))
  38.         {
  39.             case 'TEXT':
  40.             case '????':
  41.                 inputFS=*myFSS;
  42.                 HandleError(DeBinHexDispatch(), FALSE);
  43.                 break;
  44.         }
  45.     }
  46.     else
  47.     {
  48.         PositionDialog('ALRT', smallAlert);
  49.         ParamText("\pPlease wait until the current file is done before starting another.","\p","\p","\p");
  50.         StopAlert(smallAlert, 0L);
  51.     }
  52. }
  53.  
  54. OSType GetFileType(FSSpec *myFSS)
  55. {
  56.     HParamBlockRec    paramBlock;
  57.     
  58.     paramBlock.fileParam.ioCompletion=0L;
  59.     paramBlock.fileParam.ioNamePtr=myFSS->name;
  60.     paramBlock.fileParam.ioVRefNum=myFSS->vRefNum;
  61.     paramBlock.fileParam.ioFDirIndex=0;
  62.     paramBlock.fileParam.ioDirID=myFSS->parID;
  63.     PBHGetFInfo(¶mBlock, FALSE);
  64.  
  65.     return paramBlock.fileParam.ioFlFndrInfo.fdType;
  66. }
  67.